<?php

/*
 * site/home_service.php
 *
 * Provide home management service
 *
 */

require_once( 'database_fct.php' );

Service::register( 'HomeService', 'Home Service', 'Home Service' );

class HomeService extends Service
{
	public function __construct()
	{
		parent::__construct();
		$this->registerMethod( 'getText', array(), 'Get Home text', 'helpless', true );
		$this->registerMethod( 'setText', array(T_STR), 'Set Home text for current local', 'helpless', false );
	}

	public function getText()
	{
		$t = SiteDBFct::getHomeText( Locale::get() );
		if( $t == "" )
			$t = "Nothing! ahah!";
		return $t;
	}

	public function setText( $text )
	{
		$ret = false;
		if( SiteDBFct::hasHomeText(Locale::get()) )
		{
			$ret = SiteDBFct::updateHomeText( Locale::get(), $text );
		}
		else
		{
			$ret = SiteDBFct::insertHomeText( Locale::get(), $text );
		}

		return $ret;
	}
};

